﻿/**
* QSmart Andon
*
* 2012-10-10
* 
* steven.li
*
* Copyright(c) 2012 All Rights Reserved. Taiyou Tech(GUANGZHOU) Co.,Ltd.  (广州太友科技) [ sales@gztaiyou.com]. 
*
*/


namespace FX.CC.Andon.Utility.Common
{
    public sealed class SysContext //: IRequiresSessionState
    {

        public static void SetCurrent(string loginCode,string fullName,string roleId)
        {
            CurrentLoginCode = loginCode;
            CurrentFullName = fullName;
            CurrentRoleId = roleId;
        }

        public static string CurrentLoginCode
        {
            get
            {
                try
                {
                    var ctx = System.Web.HttpContext.Current;
                    var value = ctx.Session["CurrentLoginCode"];
                    return value.ToString();
                }
                catch
                {
                    return "";
                }
            }
            set
            {
                var ctx = System.Web.HttpContext.Current;
                ctx.Session["CurrentLoginCode"] = value;
            }
        }
        public static string CurrentFullName
        {
            get
            {
                try
                {
                    var ctx = System.Web.HttpContext.Current;
                    var value = ctx.Session["CurrentFullName"];
                    return value.ToString();
                }
                catch
                {
                    return "";
                }
            }
            set
            {
                var ctx = System.Web.HttpContext.Current;
                ctx.Session["CurrentFullName"] = value;
            }
        }

        public static string CurrentRoleId
        {
            get
            {
                try
                {
                    var ctx = System.Web.HttpContext.Current;
                    var value = ctx.Session["CurrentRoleId"];
                    return value.ToString();
                }
                catch
                {
                    return "";
                }
            }
            set
            {
                var ctx = System.Web.HttpContext.Current;
                ctx.Session["CurrentRoleId"] = value;
            }
        }

        private const string CurrentVerifyCode = "VerifyCode";

        /// <summary>
        /// 验证码
        /// </summary>
        public static string VerifyCode
        {
            get
            {
                try
                {
                    var ctx = System.Web.HttpContext.Current;
                    var value = ctx.Session[CurrentVerifyCode];
                    return value.ToString();
                }
                catch
                {
                    return null;
                }
            }
            set
            {
                var ctx = System.Web.HttpContext.Current;
                ctx.Session[CurrentVerifyCode] = value;
            }
        }
    }
}
